package com.team12.hotel404.service.serviceImpl;

import com.team12.hotel404.domain.Room;
import com.team12.hotel404.domain.RoomExample;
import com.team12.hotel404.mapper.RoomMapper;
import com.team12.hotel404.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    /**
     * 列出所有的房间信息
     * @return
     */
    @Override
    public List<Room> listAllRoom() {
        return roomMapper.selectByExample(new RoomExample());
    }

    /**
     * 通过房间id查看房间
     * @param id
     * @return
     */
    @Override
    public Room findRoomById(String id) {
        return roomMapper.selectByPrimaryKey(id);
    }

    /**
     * 更新单个房间的信息
     * @param room
     */
    @Override
    public void updateRoomInfo(Room room) {
        roomMapper.updateByPrimaryKeySelective(room);
    }

    @Override
    public List<Room> listByRoomType(String roomType) {
        return roomMapper.selectByRoomType(roomType);
    }

    @Override
    public List<Room> listByArea(String areaName) {
        return roomMapper.selectByArea(areaName);
    }

    @Override
    public List<Room> listByHotelName(String hotelName) {
        return roomMapper.selectByHotelName(hotelName);
    }
    @Override
    public List<Room> findRoomByHotelId(Integer hotelId){
        return roomMapper.selectByHotelId(hotelId);
    }

    @Override
    public Room findHotelIdByRoomId(String id) {
        return roomMapper.findHotelIdByRoomId(id);
    }


}
